import 'package:flutter/material.dart';
import 'index_recommond_data.dart';

var textStyle = TextStyle(fontSize: 14.0, fontWeight: FontWeight.w500);

class IndexRecommond extends StatelessWidget {
  final List<IndexRecommendItem> dataList;

  //初始化需要把数据传过来
  const IndexRecommond({Key key, this.dataList = indexRecommendData})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.all(10.0),
      decoration: BoxDecoration(color: Color(0 * 08000000)),
      child: Column(children: <Widget>[
        // Padding(
        //   padding: EdgeInsets.all(3),
        // ),
        Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            Text(
              '房屋推荐',
              style:
                  TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
            ),
            Text(
              '更多',
              style:
                  TextStyle(color: Colors.black54, fontWeight: FontWeight.w600),
            )
          ],
        ),
        Padding(
          padding: EdgeInsets.all(3),
        ),
        Wrap(
            spacing: 10.0,
            runSpacing: 10.0,
            children: dataList
                .map(
                  (item) => GestureDetector(
                    onTap: () {
                      Navigator.of(context).pushNamed(item.navigateUri);
                    },
                    child: Container(
                      alignment: Alignment.center,
                      padding: EdgeInsets.all(10.0),
                      decoration: BoxDecoration(color: Colors.white),
                      width: (MediaQuery.of(context).size.width - 10.0 * 3) / 2,
                      height: 100.0,
                      child: Row(
                        //flex b布局,水平垂直居中
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        crossAxisAlignment: CrossAxisAlignment.center,
                        children: [
                          Column(
                            //flex 布局,水平垂直居中
                            crossAxisAlignment: CrossAxisAlignment.center,
                            mainAxisAlignment: MainAxisAlignment.center,
                            children: [
                              Text(
                                item.title,
                                style: TextStyle(
                                    fontSize: 18.0,
                                    fontWeight: FontWeight.w500,
                                    color: Colors.black),
                              ),
                              Text(
                                item.subTitle,
                                style: TextStyle(
                                    fontSize: 18.0,
                                    fontWeight: FontWeight.w500,
                                    color: Colors.black),
                              ),
                            ],
                          ),
                          Image.network(
                            item.imageUri,
                            width: 55.0,
                            height: 55.0,
                          ),
                          // CommonImage(item.imageUri)
                        ],
                      ),
                    ),
                  ),
                )
                .toList()),
      ]),
    );
  }
}
